package cate.game.role.merge;

import cp.solution.util.time.DateKit;
import cate.game.GameBody;
import cate.game.role.Role;
import cp.solution.ops.status.SysOprStatus;
import cp.solution.util.time.TimeCostRecord;
import easy.java.time.DateTool;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RoleCleaner {

    private static final long NO_LOGIN_DAYS = 30;

    public static void exe(GameBody game, SysOprStatus sos, TimeCostRecord tcr, Role role) {
        tcr.start("针对单个玩家清理");
        long noLoginMs = game.time.now() - role.getStatus().loginTime;
        if(role.getPay().paySum < 600 &&
                noLoginMs > NO_LOGIN_DAYS* DateKit.DAY_MS
        ) {
            String detail = "玩家("+role.getBase().name+") lv."+role.getBase().level+" vip"+role.getBase().vip
                    +" 支付金额="+role.getPay().paySum+"分, " + DateKit.toDayHms(noLoginMs) + "没有登录了, 上次登录时间="
                    +DateTool.instance().format(role.getStatus().loginTime)+", 要被删除";
            log.info(detail);
            sos.addDetail(detail);
        }
        tcr.stop("针对单个玩家清理");
    }
}